for x in range(len(contents)): |
f = open("someTextFile2.txt","r") |
f.close() |
print(contents[x]) |
contents = f.read().split("\n") |
for x in range(len(contents)): |
f = open("someTextFile2.txt","r") |
f.close() |
    print(contents[x]) |
contents = f.read().split("\n") |
1 | f = open("someTextFile2.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | for x in range(len(contents)): |
5 |     print(contents[x]) |
6 |      |
f.close() |
f = open("someTextFile2.txt","r") |
print(contents[0]) |
contents = f.read().split("\n") |
1 | f = open("someTextFile2.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | print(contents[0]) |
contents = f.read().split("\n") |
f.close() |
f = open("someTextFile2.txt","r") |
print(contents[1]) |
1 | f = open("someTextFile2.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | print(contents[1]) |
f = open("someTextFile2.txt","r") |
line = contents[1] |
contents = f.read().split("\n") |
print(line) |
f.close() |
line = line.upper() |
1 | f = open("someTextFile2.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | line = contents[1] |
5 | line = line.upper() |
6 | print(line) |
f = open("someTextFile1.txt","r") |
for x in range(len(contents)): |
contents = f.read().split("\n") |
print(contents[x]) |
f.close() |
f = open("someTextFile1.txt","r") |
for x in range(len(contents)): |
contents = f.read().split("\n") |
    print(contents[x]) |
f.close() |
1 | f = open("someTextFile1.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | for x in range(len(contents)): |
5 |     print(contents[x]) |
6 |      |
f.close() |
f = open("someTextFile1.txt","r") |
num2 = contents[1] |
num1 = contents[0] |
contents = f.read().split("\n") |
num2 = int(num2) |
print(num1 + num2) |
num1 = int(num1) |
1 | f = open("someTextFile1.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | num1 = contents[0] |
5 | num1 = int(num1) |
6 | num2 = contents[1] |
7 | num2 = int(num2) |
8 | print(num1 + num2) |
f.close() |
index = random.randint(0,len(contents)-1) |
import random |
contents = f.read().split("\n") |
print(contents[index]) |
f = open("someTextFile2.txt","r") |
1 | import random |
2 | f = open("someTextFile2.txt","r") |
3 | contents = f.read().split("\n") |
4 | f.close() |
5 | index = random.randint(0,len(contents)-1) |
6 | print(contents[index]) |
f.close() |
f = open("someTextFile3.txt","r") |
count = count + num |
print(count) |
for x in range(len(contents)): |
contents = f.read().split("\n") |
num = contents[x] |
count = 0 |
num = int(num) |
f.close() |
f = open("someTextFile3.txt","r") |
    count = count + num |
print(count) |
for x in range(len(contents)): |
contents = f.read().split("\n") |
    num = contents[x] |
count = 0 |
    num = int(num) |
1 | f = open("someTextFile3.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | count = 0 |
5 | for x in range(len(contents)): |
6 |     num = contents[x] |
7 |     num = int(num) |
8 |     count = count + num |
9 | print(count) |
f.close() |
index = random.randint(0,len(contents)-1) |
f.close() |
import random |
contents = f.read().split("\n") |
firstName = contents[index] |
index = random.randint(0,len(contents2)-1) |
f = open("someTextFile4.txt","r") |
f = open("someTextFile5.txt","r") |
print(firstName + " " + lastName) |
lastName = contents2[index] |
contents2 = f.read().split("\n") |
1 | import random |
2 | f = open("someTextFile4.txt","r") |
3 | contents = f.read().split("\n") |
4 | f.close() |
5 | f = open("someTextFile5.txt","r") |
6 | contents2 = f.read().split("\n") |
7 | f.close() |
8 | index = random.randint(0,len(contents)-1) |
9 | firstName = contents[index] |
10 | |
11 | index = random.randint(0,len(contents2)-1) |
12 | lastName = contents2[index] |
13 | print(firstName + " " + lastName) |
return contents[index] |
def getRandom(fileName): |
contents = f.read().split("\n") |
lastName = getRandom("someTextFile5") |
f.close() |
import random |
index = random.randint(0,len(contents)-1) |
print(firstName + " " + lastName) |
firstName = getRandom("someTextFile4") |
f = open(fileName + ".txt","r") |
    return contents[index] |
def getRandom(fileName): |
    contents = f.read().split("\n") |
lastName = getRandom("someTextFile5") |
    f.close() |
import random |
    index = random.randint(0,len(contents)-1) |
print(firstName + " " + lastName) |
firstName = getRandom("someTextFile4") |
    f = open(fileName + ".txt","r") |
1 | import random |
2 | |
3 | def getRandom(fileName): |
4 |     f = open(fileName + ".txt","r") |
5 |     contents = f.read().split("\n") |
6 |     f.close() |
7 |     index = random.randint(0,len(contents)-1) |
8 |     return contents[index] |
9 | |
10 | firstName = getRandom("someTextFile4") |
11 | lastName = getRandom("someTextFile5") |
12 | print(firstName + " " + lastName) |
print(contents[x]) |
f.close() |
contents = f.read().split("\n") |
if contents[x][0].upper() == "C": |
f = open("someTextFile4.txt","r") |
for x in range(len(contents)): |
        print(contents[x]) |
f.close() |
contents = f.read().split("\n") |
    if contents[x][0].upper() == "C": |
f = open("someTextFile4.txt","r") |
for x in range(len(contents)): |
1 | f = open("someTextFile4.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | for x in range(len(contents)): |
5 |     if contents[x][0].upper() == "C": |
6 |         print(contents[x]) |
f = open(fileName + ".txt","r") |
contents = f.read().split("\n") |
for x in range(0,9): |
if x != 0: |
f.close() |
fileName = fileName + str(x) |
fileName = "someTextFile" |
print(fileName + " : " + str(len(contents))) |
  f = open(fileName + ".txt","r") |
  contents = f.read().split("\n") |
for x in range(0,9): |
  if x != 0: |
  f.close() |
    fileName = fileName + str(x) |
  fileName = "someTextFile" |
  print(fileName + " : " + str(len(contents))) |
1 | for x in range(0,9): |
2 |   fileName = "someTextFile" |
3 |   if x != 0: |
4 |     fileName = fileName + str(x) |
5 |   f = open(fileName + ".txt","r") |
6 |   contents = f.read().split("\n") |
7 |   f.close() |
8 |   print(fileName + " : " + str(len(contents))) |
f.write("\n") |
f = open("someTextFile.txt","w") |
f.close() |
f.close() |
f.write(contents[x]) |
contents = f.read().split("\n") |
f = open("someTextFile.txt","r") |
for x in range(len(contents)-1): |
  f.write("\n") |
f = open("someTextFile.txt","w") |
f.close() |
f.close() |
  f.write(contents[x]) |
contents = f.read().split("\n") |
f = open("someTextFile.txt","r") |
for x in range(len(contents)-1): |
1 | f = open("someTextFile.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | f = open("someTextFile.txt","w") |
5 | for x in range(len(contents)-1): |
6 |   f.write(contents[x]) |
7 |   f.write("\n") |
8 | f.close() |
i = input() |
countries = line[1].strip().split(",") |
f = open("someTextFile6.txt","r") |
for y in range(len(countries)): |
if line[0] == i: |
for x in range(len(contents)): |
print(countries[y]) |
f.close() |
contents = f.read().split("\n") |
line = line.split(":") |
line = contents[x] |
print("Type in a name") |
i = input() |
    countries = line[1].strip().split(",") |
f = open("someTextFile6.txt","r") |
    for y in range(len(countries)): |
  if line[0] == i: |
for x in range(len(contents)): |
      print(countries[y]) |
f.close() |
contents = f.read().split("\n") |
  line = line.split(":") |
  line = contents[x] |
print("Type in a name") |
1 | f = open("someTextFile6.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | print("Type in a name") |
5 | i = input() |
6 | for x in range(len(contents)): |
7 |   line = contents[x] |
8 |   line = line.split(":") |
9 |   if line[0] == i: |
10 |     countries = line[1].strip().split(",") |
11 |     for y in range(len(countries)): |
12 |       print(countries[y]) |
f = open("studentNames.txt","w") |
contents = f.read().split("\n") |
f = open("someTextFile7.txt","r") |
f.close() |
for x in range(len(contents)): |
break |
if contents[x][y] == "(" or contents[x][y].isdigit(): |
f.write(contents[x]) |
empty = empty + contents[x][y] |
f.write("\n") |
f.close() |
empty = "" |
for y in range(len(contents[x])): |
for x in range(len(contents)): |
contents[x] = empty.strip() |
f = open("studentNames.txt","w") |
contents = f.read().split("\n") |
f = open("someTextFile7.txt","r") |
f.close() |
for x in range(len(contents)): |
      break |
    if contents[x][y] == "(" or contents[x][y].isdigit(): |
  f.write(contents[x]) |
    empty = empty + contents[x][y] |
  f.write("\n") |
f.close() |
  empty = "" |
  for y in range(len(contents[x])): |
for x in range(len(contents)): |
  contents[x] = empty.strip() |
1 | f = open("someTextFile7.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | for x in range(len(contents)): |
5 |   empty = "" |
6 |   for y in range(len(contents[x])): |
7 |     if contents[x][y] == "(" or contents[x][y].isdigit(): |
8 |       break |
9 |     empty = empty + contents[x][y] |
10 |   contents[x] = empty.strip() |
11 | f = open("studentNames.txt","w") |
12 | for x in range(len(contents)): |
13 |   f.write(contents[x]) |
14 |   f.write("\n") |
15 | f.close() |
contents = f.read().split("\n") |
names.append(names[0].title()) |
while True: |
names.pop(0) |
for x in range(len(contents)): |
for x in range(len(contents)): |
contents[x] = " ".join(names) |
else: |
f = open("someTextFile8.txt","r") |
names = contents[x].split(" ") |
f = open("studentNames.txt","w") |
f.write("\n") |
f.close() |
break |
if names[0] != names[0].upper(): |
f.write(contents[x]) |
f.close() |
contents = f.read().split("\n") |
      names.append(names[0].title()) |
  while True: |
      names.pop(0) |
for x in range(len(contents)): |
for x in range(len(contents)): |
  contents[x] = " ".join(names) |
    else: |
f = open("someTextFile8.txt","r") |
  names = contents[x].split(" ") |
f = open("studentNames.txt","w") |
  f.write("\n") |
f.close() |
      break |
    if names[0] != names[0].upper(): |
  f.write(contents[x]) |
f.close() |
1 | f = open("someTextFile8.txt","r") |
2 | contents = f.read().split("\n") |
3 | f.close() |
4 | for x in range(len(contents)): |
5 |   names = contents[x].split(" ") |
6 |   while True: |
7 |     if names[0] != names[0].upper(): |
8 |       break |
9 |     else: |
10 |       names.append(names[0].title()) |
11 |       names.pop(0) |
12 |   contents[x] = " ".join(names) |
13 | f = open("studentNames.txt","w") |
14 | for x in range(len(contents)): |
15 |   f.write(contents[x]) |
16 |   f.write("\n") |
17 | f.close() |